package com.dps.omc.mq.consumer.impl;

import com.dps.omc.model.Task;
import com.dps.omc.service.ILogFileService;
import com.dps.omc.service.ITaskService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by lip on 2016-05-17.
 */
public class UploadLogThread implements Runnable{

    private static final Logger logger = LoggerFactory.getLogger(UploadLogThread.class);

    private String taskId;
    private String returnMsg;
    private ITaskService taskService;
    private ILogFileService logFileService;

    public UploadLogThread(String taskId,String returnMsg,ITaskService taskService,ILogFileService logFileService)
    {

        this.taskId = taskId;
        this.returnMsg = returnMsg;
        this.taskService = taskService;
        this.logFileService = logFileService;
    }

    @Override
    public void run() {
        try {
//            this.jobManager.run(this.job,this.lastModified);
            String logFileId = logFileService.create(this.taskId,this.returnMsg);

            Task task = new Task();
            task.setId(taskId);
            task.setLogFileId(logFileId);
            taskService.update(task);

        } catch (Exception e) {
            logger.error(e.toString());
        }
    }
}
